package com.uliian.upyundemo.config;

import com.uliian.upyundemo.utils.UpyunUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.security.NoSuchAlgorithmException;

@Configuration
@ConfigurationProperties(prefix = "upyun")
public class UpyunConfig {
    private String operator;
    private String password;
    private String md5Password;

    public String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    private String bucketName;

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getMd5Password() throws NoSuchAlgorithmException {
        if(md5Password==null){
            md5Password = UpyunUtils.md5(this.password);
        }
        return this.md5Password;
    }
}
